package com.excetop.xservlet.req.param;

import com.alibaba.fastjson.JSON;

/**
 * JSON 参数
 * @author xuZW
 *
 */
public class JsonParam extends TextParam {

	private Object jsonValue;
	
	private Object[] jsonValueArray;

	public JsonParam() {
	}
	
	public JsonParam(String name, String[] textValueArray) {
		this(name, textValueArray, null);
	}
	
	public JsonParam(String name, String[] textValueArray, String[] patternArray) {
		super(name, textValueArray, patternArray);
		setType(TYPE_JSON);
		String[] texts = getTextValueArray();
		if(null != texts && texts.length > 0){
			jsonValueArray = new Object[texts.length];
			for (int i = 0; i < jsonValueArray.length; i++) {
				try { jsonValueArray[i] = JSON.parse(texts[i]); }
				catch (Exception e) { }
			}
		}
		if(null != jsonValueArray && jsonValueArray.length > 0){
			jsonValue = jsonValueArray[0];
		}
	}
	
	public Object getJsonValue() {
		return jsonValue;
	}

	public void setJsonValue(Object jsonValue) {
		this.jsonValue = jsonValue;
	}

	public Object[] getJsonValueArray() {
		return jsonValueArray;
	}

	public void setJsonValueArray(Object[] jsonValueArray) {
		this.jsonValueArray = jsonValueArray;
	}
	
	@Override
	public boolean verifying() {
		boolean result = true;
		// TODO Auto-generated method stub
		return result;
	}
	
}
